#include "game.h"
#include <vector>
#include <random>
#include <numeric>
std::vector<int> guess(int n, int limit){
#define ALL(vc) (vc).begin(),(vc).end()
	using namespace std;
	typedef long long ll;
	typedef __int128 lll;
	lll md=((lll)1<<64)/n;
	typedef vector<int> vi;
	vector<vi> vis(n,vi(n));
	vi c(n);
	mt19937 rng(random_device{}());
	auto qry=[&]()->int{
		lll x=rng();
		x-=((x*md)>>64)*n;
		while(x>=n) x-=n;
		return x;
	};
	int ss=0;
	int cnt=0;
	vi a(n);
	while(ss<n){
tmp:
		int x=qry();
		while(c[x]==n-1) x=qry();
		int y=qry();
		while(vis[x][y]) y=qry();
		vi aa(n-1);
		int rk=0;
		for(int i=0;i<n;++i) if(i!=y) aa[rk++]=i+1;
		shuffle(ALL(aa),rng);
		rk=0;
		for(int i=0;i<n;++i)
			if(i!=x) a[i]=aa[rk++];
			else a[i]=y+1;
		for(int i=0;i<n;++i)
			if(c[i]==n-1&&!vis[i][a[i]-1]) goto tmp;
		if(!count(a)){
			for(int i=0;i<n;++i)
				if(!vis[i][a[i]-1]){
					vis[i][a[i]-1]=1;
					if(++c[i]==n-1) ++ss;
				}
		}
	}
	vi res(n);
	for(int i=0;i<n;++i)
		res[i]=find(ALL(vis[i]),0)-vis[i].begin()+1;
	return res;
#undef ALL
}
